
//// change password window and actions

var modThemes = new Class({
            Extends:boxWindow,
			options: {
				width: 400,
				height: 400,
				BtnRefresh: false,
				BtnMin: false,
				BtnSettings: false,
				title: lang.label('settings_themes'),
				name: 'modThemes',
				uniqueCss: false,
				closeconfirm: false,
				modal: true
			},					  
			
			
			//show window
			initialize: function(initial){
				this.parent(this.options);
				
				var content = '<div  style="padding: 8px; width: 95%;"><div style="overflow:auto;height:380px">'; 
				
				for(var i = 0 ; i < themes.length ; i++){
					content += '<div><h1>'+themes[i]+' - <a href="javascript:void(0)" onclick="javascript:setTheme(\''+themes[i]+'\')">'+lang.label('apply_this_theme')+'</a></h1></div>';
					content += '<div style="padding-bottom:20px"><a href="javascript:void(0)" onclick="javascript:setTheme(\''+themes[i]+'\')"><img src="theme/'+themes[i]+'/img/thumbnail.jpg"></a></div>';
				}
				content += '</div></div>';
				 
				this.fillTitle(this.options.title);
				this.fillContent(content);
				
				//increase the height of the grayed sreen
				$('overlay').setStyle('height', getFullHeight() +'px');   
			},
			
			/////// change pass request to db
			changepass: function(){
				$('btn_cpass').setProperty('disabled' , true);
				
				var opass = $('opass').getProperty('value').trim();
				var passw = $('password').getProperty('value').trim();
				var passw2 = $('password2').getProperty('value').trim();
				
				if(passw == "" || passw2 == "" || passw.length < 6 || passw2.length < 6 || (passw != passw2) ){
					alert(lang.label('auth_msg_pwd_invalid'));	
					$('btn_cpass').setProperty('disabled' , false);
					return false;
				}
				
				if(opass != "" && passw != "" && passw2 != "" && ( passw2 == passw )){
					this.sendData("act=change&opass=" + opass + "&password=" + passw, this.cpResponse);	
				}else{
					alert(lang.label('auth_input_invalid'));	
					$('btn_cpass').setProperty('disabled' , false);
				}
			},
			
			
			///act on response
			cpResponse: function(request){
				if(request == 'passfail'){
					alert(lang.label('auth_msg_pwd_invalid'));	
					$('btn_cpass').setProperty('disabled' , false);
				}else if(request == 'falsepass'){
					alert(lang.label('settings_old_pwd_wrong'));	
					$('btn_cpass').setProperty('disabled' , false);
				}else if(request != ''){
					Cookie.set('un' , request, {path: wf_cookie_path});
					alert(lang.label('settings_pwd_changed'));	
					$('btn_cpass').setProperty('disabled' , false);
				}else{
					alert('unexpected error');	
					$('btn_cpass').setProperty('disabled' , false);
				}
			}
	});
